package dao;

import com.mysql.jdbc.PreparedStatement;
import generics.GenericoDao;
import dto.Permissao;
import factory.daoUtil;
import java.sql.ResultSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Permissoes implements GenericoDao<Permissao> {
    
    public List<Permissao> select() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    public boolean insert(Permissao ob) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    public boolean edit(Permissao ob) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    public Permissao view(Permissao ob) {
        Permissao permOb = new Permissao();
        
        String sql = "SELECT * FROM blogdb.permissao WHERE id = ?";
        
        try {
            try {
                
                PreparedStatement ps = (PreparedStatement) daoUtil.getInstance().getPrepareStatemen(sql);
                ps.setInt(1, ob.getId());
                
                ResultSet rs = ps.executeQuery();
                
                while (rs.next()) {
                    permOb.setId(rs.getInt("id"));
                    permOb.setDescricao(rs.getString("descricao"));
                }
                
            } catch (Exception ex) {
                Logger.getLogger(Categorias.class.getName()).log(Level.SEVERE, null, ex);
            }
        } finally {
            daoUtil.getInstance().fecharTudo();
        }
        
        return permOb;
    }
    
    public boolean delete(Permissao ob) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
